import React, { Component } from "react";
import "./style.css";
class homepage extends Component {
  // react 初始化生命周期
  // 初始化页面
  componentDidMount() {
    console.log(JSON.parse(this.props.match.params.logIndata));
    var logIndata = JSON.parse(this.props.match.params.logIndata);
    this.setState({
      username: logIndata.username,
      password: logIndata.password,
    });
  }
  // 构造周期
  constructor() {
    super();
    this.state = {
      username: "",
      password: "",
    };
  }
  goBack = () => {
    this.props.history.go(-1);
  };
  goLifeCycle = () => {
    this.props.history.push("/LifeCycle");
  };
  render() {
    var username = this.state.username;
    var password = this.state.password;
    return (
      <div>
        <h1>homepage</h1>
        <p>{username}</p>
        <p>{password}</p>
        <button onClick={this.goBack.bind(this)}> 返回</button>
        {/* <button onClick={this.goLifeCycle.bind(this)}> 生命周期</button> */}
      </div>
    );
  }
}
export default homepage;
